package com.asa.physics;

import com.asa.hutils.Ni;
import com.asa.physics.bean.Point;
import com.asa.physics.bean.ShiLiang;

/**
 * 判别解析几何中对象的关系
 * @author Administrator
 *
 */
public class NormPanBie {

	/**
	 * 判断一个平面中三点是否共线
	 * @param p
	 * @param q
	 * @param s
	 * @return
	 */
	public static boolean inline(Point p,Point q,Point s) {
		double asa = p.x * q.y - p.y * q.x + q.x * s.y - q.y * s.x + s.x * p.y - s.y * p.x;
		return asa==0;
	}
	
	/**
	 * 判断两矢量垂直
	 * @param p
	 * @param q
	 * @param s
	 * @return
	 */
	public static boolean chuizhi(ShiLiang s1,ShiLiang s2) {
		double asa = Norm.shiliang_biaoliangji(s1, s2);
		return asa==0;
	}
	
	/**
	 * 判断两矢量是否平行
	 * @param s1
	 * @param s2
	 * @return
	 */
	public static boolean pingxin(ShiLiang s1,ShiLiang s2) {
		ShiLiang a = Norm.shiliang_shiliangji(s1, s2);
		double asa = a.xyz[0]*a.xyz[0]+a.xyz[1]*a.xyz[1]+a.xyz[2]*a.xyz[2];
		return asa==0;
	}
	/**
	 * 两个向量是否共面
	 * @param p
	 * @param q
	 * @param s
	 * @param t
	 * @return
	 */
	public static boolean gongmian(Point p,Point q,Point s,Point t) {
		
		double[][] a = {{p.x-t.x,q.x-t.x,s.x-t.x},{p.y-t.y,q.y-t.y,s.y-t.y},{p.z-t.z,q.z-t.z,s.z-t.z}};
		double asa = Ni.hangleishivalue(a);
		return asa==0;
		
	}
	
	
	
	/**
	 * 两个面的关系
	 * 平行
	 * 相交
	 * 重合
	 * 这三种关系
	 */
	public static String lianmianguanxin(double A1,double B1,double C1,double D1,
			double A2,double B2,double C2,double D2) {
		double a = A1/A2;
		double b = B1/B2;
		double c = C1/C2;
		double d = D1/D2;
		if (a==b&&b==c) {
			if (c==d) {
				return "重合";
			}
			return "平行";
			
		}
		return "相交";
	}

	
	
	
	/**
	 * 三个面的关系
	 * 交于一点
	 * 这一种关系
	 */
	public static boolean sanmian(double A1,double B1,double C1,double D1,
			double A2,double B2,double C2,double D2,
			double A3,double B3,double C3,double D3) {
		
		
		double[][] a = {{A1,B1,C1},{A2,B2,C2},{A3,B3,C3}};
		double asa = Ni.hangleishivalue(a);
		return asa==0;
	}

	
	
	
	
	
	
	
	
	
	
	/**
	 * 线段的定比分点
	 * @param x
	 * @param a
	 * @return
	 */
	public static Point aLine(Point p,Point q,double a) {
		
		Point result = new Point();
		
		result.x = (p.x+a*q.x)/(1+a);
		result.y = (p.y+a*q.y)/(1+a);
		result.z = (p.z+a*q.z)/(1+a);
		return result;

	}
	
	
	
	
	
	
	
}
